package com.atguigu.jxc.controller;

import com.atguigu.jxc.domain.ServiceVO;
import com.atguigu.jxc.entity.Supplier;
import com.atguigu.jxc.service.SupplierService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@RequestMapping("supplier")
public class SupplierController {
   /* @Autowired
    private ServiceVO serviceVO;*/

    @Autowired
    private SupplierService supplierService;

    //分页查询供应商
    @PostMapping("/list")
    public Map<String,Object> selectSupplierPage(Integer page, Integer rows, String supplierName){
        return supplierService.selectSupplierPage(page,rows,supplierName);
    }


    /**
     * 供应商添加或修改
     * @param supplier
     * @return
     */
    @PostMapping("/save")
    public ServiceVO saveOrUpdateSupplier( Supplier supplier) {
        return supplierService.saveOrUpdateSupplier(supplier);

    }

    /**
     * 删除供应商
     * @param ids
     * @return
     */
    @PostMapping("/delete")
    public ServiceVO deleteSupplier(String ids) {
        String[] split = ids.split(",");
        return supplierService.deleteSupplier(split);
    }
}
